home *** CD-ROM | disk | FTP | other *** search
/ Pascal Super Library / Pascal Super Library (CW International)(1997).bin / LIBRARY / PAS_0493 / STRUPPER.PAS < prev    next >
Pascal/Delphi Source File  |  1993-04-15  |  4KB  |  73 lines

  1. {─ Fido Pascal Conference ────────────────────────────────────────────── PASCAL ─
  2. Msg  : 365 of 367
  3. From : Peter Beeftink                      1:163/307.25         11 Apr 93  16:03
  4. To   : Bo Bendtsen                         2:231/111.0
  5. Subj : International characters
  6. ────────────────────────────────────────────────────────────────────────────────
  7. Hello Bo!
  8.  
  9. Friday April 09 1993 12:28, Bo Bendtsen wrote to All:
  10.  
  11.  BB>   Upper/lower changing of strings are always a difficult problem,
  12.  BB>   but as a person living in Denmark i must normally care about
  13.  BB>   danish characters,
  14.  
  15. Possibly you like the method as shown underneath Bo!  I picked this up in this
  16. echo I believe.  You can modify the 'special changes' as required.
  17.  
  18. Peter      }
  19.  
  20. function StrUpper(Str: String): String; Assembler;
  21.  ASM
  22.       jmp   @Start { Jump over Table declared in the Code Segment }
  23.  
  24.   @Table:
  25.     { characters from ASCII 0 --> ASCII 96 stay the same }
  26.   DB 00,01,02,03,04,05,06,07,08,09,10,11,12,13,14,15,16,17,18,19,20,21
  27.   DB 22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43
  28.   DB 44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65
  29.   DB 66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87
  30.   DB 88,89,90,91,92,93,94,95,96
  31.     { characters from ASCII 97 "a" --> ASCII 122 "z" get translated }
  32.     { to characters ASCII 65 "A" --> ASCII 90 "Z" }
  33.   DB 65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86
  34.   DB 87,88,89,90
  35.     { characters from ASCII 123 --> ASCII 127 stay the same }
  36.   DB 123,124,125,126,127
  37.     { characters from ASCII 128 --> ASCII 165 some changes
  38.      #129 --> #154, #130 --> #144, #132 --> #142, #134 --> #143
  39.       #135 --> #128, #145 --> #146, #148 --> #153, #164 --> #165}
  40.  
  41.   DB 128,154,144,131,142,133,143,128,136,137,138,139,140,141,142,143
  42.   DB 144,146,146,147,153,149,150,151,152,153,154,155,156,157,158,159
  43.   DB 160,161,162,163,165,165
  44.     { characters from ASCII 166 --> ASCII 255 stay the same }
  45.   DB 166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181
  46.   DB 182,183,184,185,186,187,188,189,190,191,192,193,194,195,196,197
  47.   DB 198,199,200,201,202,203,204,205,206,207,208,209,210,211,212,213
  48.   DB 214,215,216,217,218,219,220,221,222,223,224,225,226,227,228,229
  49.   DB 230,231,232,233,234,235,236,237,238,239,240,241,242,243,244,245
  50.   DB 246,247,248,249,250,251,252,253,254,255
  51.  
  52.   @Start:
  53.       push  DS                { Save Turbo's Data Segment address    }
  54.       lds   SI,Str            { DS:SI points to Str[0]               }
  55.       les   DI,@Result        { ES:DI points to StrUpper[0]          }
  56.       cld                     { Set direction to forward             }
  57.       xor   CX,CX             { CX = 0                               }
  58.       mov   BX,OFFSET @Table  { BX = Offset address of LookUpTable   }
  59.       lodsb                   { AL = Length(Str); SI -> Str[1]       }
  60.       mov   CL,AL             { CL = Length(Str)                     }
  61.       stosb                   { Move Length(Str) to Length(StrUpper) }
  62.       jcxz  @Exit             { Get out if Length(Str) is zero       }
  63.  
  64.   @GetNext:
  65.       lodsb                   { Load next character into AL          }
  66.       segcs XLAT              { Translate char using the LookupTable }
  67.                               { located in Code Segment at offset BX }
  68.       stosb                   { Save next translated char in StrUpper}
  69.       loop  @GetNext          { Get next character                   }
  70.  
  71.   @Exit:
  72.       pop   DS                { Restore Turbo's Data Segment address }
  73.  end {StrUpper};